﻿@{
    ViewBag.SubTitle = "现金账户";
    Layout = "~/Views/Shared/_LayoutBlank.cshtml";
}

<style type="text/css">
    body {
        /*margin-top: 1.5rem;*/
         margin-top: 1.2rem;
        margin-bottom: 0.55rem;
    }

    #divTopTitleBar {
        position: fixed;
        left: 0rem;
        right: 0rem;
        /*top: 1rem;*/
         top:0.7rem;
        height: 0.4rem;
        background-color: white;
    }

    .divBillTitle {
        font-size: 0.13rem;
    }

    .divBillDateTime {
        font-size: 0.13rem;
    }

    .divPointIncrement {
        color: #FF541B;
        font-weight: bold;
        font-size: 0.16rem;
    }

    .divPointDecrement {
        color: #00B200;
        font-weight: bold;
        font-size: 0.16rem;
    }

    #divFooter {
        position: fixed;
        bottom: 0px;
        left: 0px;
        right: 0px;
        height: 0.4rem;
        font-size: 0.14rem;
        text-align: center;
        background-color: #F5F5F5;
    }
</style>

<script>

    //当前页
    var _currentPage = 1;
    var _totalPage = 1;

    $(document).ready(function () {
        loadData();
    });

    function loadData(targetPage) {
        if (targetPage > _totalPage)
            return;

        var loadLayerIndex = layer.open({
            type: 2,
            shadeClose: false,
            content: '请稍候...'
        });

        var args = new Object();
        args.Page = targetPage || 1;
        args.PageSize = 10;

        $.ajax({
            url: "/Api/Pay/GetCashAccountTrackList/@ViewBag.Domain.Id",
            type: "POST",
            dataType: "json",
            data: JSON.stringify(args),
            success: function (data, status, jqXHR) {
                // alert(data);

                layer.close(loadLayerIndex);
                if (data.Success) {
                    var resultObj = data.Data;

                    _currentPage = resultObj.Page;
                    _totalPage = resultObj.TotalPage;
                    if (_currentPage >= _totalPage) {
                        $("#divPagingContainer").html("没有更多了");
                    }

                    if (_currentPage == 1) {
                        document.getElementById('cashAccountTrackListContainer').innerHTML = "";
                    }

                    var gettpl = document.getElementById('itemListTemplate').innerHTML;
                    laytpl(gettpl).render(resultObj.ItemList, function (html) {
                        document.getElementById('cashAccountTrackListContainer').innerHTML += html;
                    });

                } else {
                    layerAlert(data.Message);
                }
            },
            error: function (xmlHttpRequest) {
                layer.close(loadLayerIndex);
                //alert("Error: " + xmlHttpRequest.status);
            }
        });
    }

    function deposit() {
        window.location.href = '/Pay/Deposit/@ViewBag.Domain.Id';
    }

    function payOrderList() {
        window.location.href = '/Pay/PayOrderList/@ViewBag.Domain.Id';
    }

</script>

<script id="itemListTemplate" type="text/html">

    {{# for(var i = 0, len = d.length; i < len; i=i+1){ }}

    <div style="margin-top:0.1rem;">
        <div>
            <div style="float:left" class="divBillTitle">
                {{# if(d[i].Type == 0){ }}
                未知
                {{# }else if(d[i].Type == 1){ }}
                账户充值
                {{# }else if(d[i].Type == 2){ }}
                一般消费
                {{# }else if(d[i].Type == 3){ }}
                现金充值
                {{# }else if(d[i].Type == 4){ }}
                现金退款
                {{# }else if(d[i].Type == 5){ }}
                1元夺宝
                {{# }else if(d[i].Type == 6){ }}
                积分商城
                {{# } }}
            </div>
            <div style="float:right" class="divBillDateTime">
                {{ d[i].ChangeTime }}
            </div>
            <div style="clear:both"></div>
        </div>
        <div style="margin-top:0.1rem;">
            <div style="float:left" class="{{# if(d[i].Fee >= 0){ }}divPointIncrement{{# }else{ }}divPointDecrement{{# } }}">
                {{# if(d[i].Fee >= 0){ }}
                +{{#}}}{{d[i].Fee/100}}
            </div>
            {{# if(d[i].Remark != undefined && d[i].Remark != null && d[i].Remark != ''){ }}
            <div style="float:right">
                <div>{{ d[i].Remark }}</div>
            </div>
            {{# } }}
            <div style="clear:both"></div>
        </div>
    </div>



    <div class="divDotLine" style="margin-top:0.13rem; margin-bottom:0.13rem; ">
    </div>

    {{# } }}

</script>

@Helpers.HeaderArea(ViewBag, "cash")

<div id="divTopTitleBar">
    <table width="100%" border="0" cellspacing="0" cellpadding="0" style="height:100%">
        <tr style="height:0.27rem;">
            <td width="33%" align="center"><div onclick="goUrl('/Home/PointAccount/@ViewBag.Domain.Id')">积分账户</div></td>
            <td width="33%" align="center"><div onclick="goUrl('/Pay/CashAccountTrack/@ViewBag.Domain.Id')">现金账户</div></td>
            <td width="33%" align="center"><div onclick="goUrl('/Home/Coupon/@ViewBag.Domain.Id')">我的卡券</div></td>
        </tr>
        <tr style="height:0.03rem;">
            <td bgcolor="#E4E4E4"></td>
            <td class="defaultBgColor"></td>
            <td bgcolor="#E4E4E4"></td>
        </tr>
    </table>

</div>

<div class="divContent" style="margin-top:0.1rem;">

    <div id="cashAccountTrackListContainer" style="padding-left: 0.1rem; padding-right: 0.1rem;margin-top:0.2rem;">
    </div>

    <div id="divPagingContainer" class="divPagingContainer" style="margin-top:0.2rem; text-align:center" onclick="loadData(_currentPage + 1)">
        查看更多
    </div>

</div>

<div id="divFooter">
    <table align="center" border="0" style="height:100%;width:100%">
        <tr>
            <td valign="middle" align="center" width="50%">
                <input name="" type="button" class="button" value="在线充值" style="width:90%" onclick="deposit()">
            </td>
            <td valign="middle" align="center" width="50%">
                <input name="" type="button" class="button" value="支付订单" style="width:90%" onclick="payOrderList()">
            </td>
        </tr>
    </table>
</div>